RGBSurface Class

Used for direct-color pixel manipulations. The RGBSurface property of a Picture object allows you to manipulate the picture at the pixel level.

Events

None

Properties

None

Methods

FloodFill

Pixel

Transform


Can be used only for pictures created by NewPicture with a pixel depth of 16 or 32.

Pixel manipulations using the RGBSurface property are faster than the same manipulations using the Graphics class methods.


Example

This example replaces all the black pixels in a Picture, somePicture, with white:

Dim surf As RGBSurface
Dim x, y As Integer
surf = somePicture.RGBSurface
For y = somePicture.height - 1 downTo 0
 For x = somePicture.width - 1 downTo 0
  If surf.Pixel(x,y) = &c000000 then surf.Pixel(x,y) =&cFFFFFF
 next
next

The following example uses the FloodFill method to paint an RGBSurface object in a random color. It is in the MouseDown event of a Canvas control. The variable p is a Picture object.

Dim randomColor as Color
randomColor= RGB( Rnd*255, Rnd*255, Rnd*255)  //create random color
p.RGBSurface.FloodFill x,y,randomColor  //fill the area with the color
Me.Graphics.DrawPicture p,0,0  //repaint the canvas control

The following example uses the Transform method to invert an image:

Dim map(255), i as Integer
For i = 0 to 255
 map(i) = 255 - i
next
somePicture.RGBSurface.Transform map

Note

32-bit RGBSurface objects are mapped to 24-bit objects on Windows.


See Also

RGBSurface property of the Picture object.